<div class="container-fluid">
	<div id="pad-wrapper">
		<!-- products table-->
		<!-- the script for the toggle all checkboxes from header is located in js/theme.js -->
		<div class="table-wrapper products-table section">
			<div class="row-fluid head">
				<div class="span12">
					<h4>医生个人推广列表</h4>
				</div>
			</div>


			<form action="" method="get" name="search">
				<div class="row-fluid filter-block">
					<!--
					<div class="pull-left">
						<a class="btn-flat success" onclick="document.forms['batch'].submit();">批量通过</a>
					</div> -->
					<div class="pull-left">
						<input type="hidden" name="id" id="id" value="<?php echo $id ?>" style="width: 10%;"/>
						微信昵称：
						<input type="text" class="search" name="wx_name" value="<?php echo $wx_name?>" style="width: 10%;" />
						关注起始时间：
						<input type="text" style="cursor: default;width:10%" onclick="WdatePicker()" readonly="readonly" class="search" name="start_time" value="<?php echo $start_time?>" />
						关注结束时间：
						<input type="text" style="cursor: default;width:10%" onclick="WdatePicker()" readonly="readonly" class="search" name="end_time" value="<?php echo $end_time?>" />

						状态：
						<select class="search" name="tag">
							<option value="4" <?php if(@$tag == 4) echo 'selected = "selected"' ?> >所有</option>
							<option value="0" <?php if(@$tag == 0) echo 'selected = "selected"' ?> >扫码关注，未生产订单</option>
							<option value="1" <?php if(@$tag == 1) echo 'selected = "selected"' ?> >订单生产，未支付</option>
							<option value="2" <?php if(@$tag == 2) echo 'selected = "selected"' ?> >已支付，已核算给推广人</option>
							<option value="3" <?php if(@$tag == 3) echo 'selected = "selected"' ?> >核算时过期，不算推广人业绩</option>
						</select>

						<a class="btn-flat success" onclick="document.forms['search'].submit();">查询</a>
					</div>
					<!--
					<div class="pull-right">
						<a class="btn-flat success" id="updateUserInfo">昵称及头像更新</a>
					</div>
					-->
				</div>
			</form>

			<div class="row-fluid">
				<table class="table table-hover">
					<thead>
					<tr>
						<!-- <th class="span3"><input type="checkbox" /> 头像</th> -->
						<th class="span1"><span class="line"></span> 头像</th>
						<th class="span2"><span class="line"></span>微信昵称</th>
						<th class="span3 clickable_time"><span class="line"></span>关注时间<span class="<?php
							if(!isset($_GET['sort_time'])){
								echo 'icon icon-chevron-down';
							} elseif($_GET['sort_time'] == 'asc') {
								echo 'icon icon-chevron-up';
							}elseif($_GET['sort_time'] == 'desc'){
								echo 'icon icon-chevron-down';
							}else{
								echo 'icon icon-chevron-down';
							}
							?>"></span></th>
						<th class="span1"><span class="line"></span>推广有限时间</th>
						<th class="span2"><span class="line"></span>状态</th>
					</tr>
					</thead>
					<form action="/organization-apply/batch" method="post" name="batch">
						<tbody>
						<?php if($spreadList):?>
							<?php foreach ($spreadList as $item):?>
								<!-- row -->
								<tr class="first">
									<td >
										<img height="40" width="40" src="<?php echo $item['headimgurl']?>" />
									</td>
                                    <td class="wx_name"><?php echo $item['nickname']?></td>
									<td class="create_time"><?php echo date('Y-m-d G:i:s',$item['create_time'])?></td>
									<td class="effective_time"><?php echo date('Y-m-d G:i:s',$item['effective_time'])?></td>
									<td class="status"><?php
										if($item['spread_status'] == 0){
											echo "扫码关注，未生产订单";
										}elseif($item['spread_status'] == 1){
											echo "订单生产，未支付";
										}elseif($item['spread_status'] == 2){
											echo "已支付，已核算给推广人";
										}elseif($item['spread_status'] == 3){
											echo "核算时过期，不算推广人业绩";
										}
										?></td>
								</tr>
							<?php endforeach;?>
						<?php endif;?>
						</tbody>
					</form>
				</table>
			</div>
		</div>
		<!-- end products table -->
	</div>
	<div class="pagination pull-right">
		<?php echo $pagination;?>
	</div>
<!--Edited by ysy Start-->
	<script type="text/javascript">
		$(function () {
		<!--表格标题点击排序-->
		$("th.clickable_time").click(function () {
			var param=$(this).data("param" );
			if (!$("th.clickable_time .icon.icon-chevron-down").length>0) {
				$(this).find(".icon").addClass("icon-chevron-down").removeClass("icon-chevron-up");
				var  $namev = $('input[name="wx_name"]').val();
				var  $start_time = $('input[name="start_time"]').val();
				var  $end_time = $('input[name="end_time"]').val();
				var  $id = $('input[name="id"]').val();
				var  $url = '/doctor/spreadlist?id='+$id+"&wx_name="+$namev+"&sort_time=desc"+"&start_time="+$start_time+"&end_time="+$end_time;
				$.ajax({
					type:'get',
					url:$url,
					cache:false,
					dataType:'json',
					success:function(data){
//						window.location.reload($url);//刷新当前页面.
						location.href =$url;
					},
					error:function(){
//						window.location.reload($url);//刷新当前页面.
						location.href =$url;
					}
				});
			}
			else {
			$(this).find(".icon").addClass("icon-chevron-up").removeClass("icon-chevron-down");
				var  $namev = $('input[name="wx_name"]').val();
				var  $start_time = $('input[name="start_time"]').val();
				var  $end_time = $('input[name="end_time"]').val();
				var  $id = $('input[name="id"]').val();
				var  $url = '/doctor/spreadlist?id='+$id+"&wx_name="+$namev+"&sort_time=asc"+"&start_time="+$start_time+"&end_time="+$end_time;
				$.ajax({
					type:'get',
					url:$url,
					cache:false,
					dataType:'json',
					success:function(data){
//						window.location.reload($url);//刷新当前页面.
						location.href =$url;
					},
					error:function(){
//						window.location.reload($url);//刷新当前页面.
						location.href =$url;
					}
				});
				}
		});

		$("#updateUserInfo").click(
			function () {
				$("#updateUserInfo").html("更新中.......");
				$.ajax({
					type:'post',
					url:'#',
					cache:false,
					dataType:'json',
					success:function(data){

						if(data.result == 1)//success
						{
							window.location.reload();//刷新当前页面.
							$("#updateUserInfo").html("更新完成");
						}else{
							$("#updateUserInfo").html("更新完成,失败");
						}
					},
					error:function(){
						alert("失败");
						$("#updateUserInfo").html("更新完成,失败");
					}
				});
			}
		);
		});
	</script>
	<style>
		th{
			text-align: center !important;
		}
        table td{
            text-align: center !important;
        }
		table th span.line{
			left:0 !important;
		}
		th.clickable{
			cursor:pointer;
		}
		th.clickable_time{
			cursor:pointer;
		}
		th.clickable .icon{
			margin-left:10px;
		}
		th.clickable_time .icon{
			margin-left:10px;
		}
	</style>
<!--Edited by ysy End-->
</div>